<template>
  <div>
    <el-form label-width="500px">
      <div>
        <el-form-item style="width: 750px" label="管理员姓名">
          <el-input v-model="admins.name" type="text"></el-input>
        </el-form-item>
      </div>
      <div>
        <el-form-item style="width: 750px" label="管理员账号">
          <el-input v-model="admins.account" type="text"></el-input>
        </el-form-item>
      </div>
      <div>
        <el-form-item style="width: 750px" label="管理员密码">
          <el-input v-model="admins.password" type="text"></el-input>
        </el-form-item>
      </div>
      <div>
        <el-button type="warning" @click="updateAdmin(admins)"
          >确认修改</el-button
        >
      </div>
    </el-form>
  </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions, mapState } = createNamespacedHelpers("admins");
import AdminsList from "./AdminsList.vue";
export default {
  created() {
    this.getAdminById(this.$route.params._id);
  },
  props: ["_id"],
  computed: {
    ...mapState(["admins"]),
  },

  methods: {
    ...mapActions(["updateAdmin", "getAdminById"]),
  },

  data() {
    return {
      form: {},
      admin: {},
      name: localStorage.adminname,
      account: localStorage.adminaccount,
      password: localStorage.adminpassword,
    };
  },
};
</script>